/*
 * @Description: 时间选择快捷选项
 * @Author: liushuang
 * @Date: 2022-07-11 11:26:29
 * @LastEditTime: 2022-10-14 14:39:19
 */
import { getCurrentWeek, getCurrentMonth } from 'web-utils-super'

const shortcuts = [
  {
    text: '今天',
    value: () => {
      const start = new Date()
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      const end = new Date()
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '昨天',
    value: () => {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      const date2 = new Date()
      date2.setTime(date2.getTime() - 3600 * 1000 * 24)
      const start = date2
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      const end = date
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '本周',
    value: () => {
      let [start, end] = getCurrentWeek(new Date())
      start = new Date(start)
      end = new Date(end)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '上周',
    value: () => {
      let [start, end] = getCurrentWeek(new Date() - 3600 * 1000 * 24 * 7)
      start = new Date(start)
      end = new Date(end)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '本月',
    value: () => {
      let [start, end] = getCurrentMonth(new Date())
      start = new Date(start)
      end = new Date(end)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '上月',
    value: () => {
      let [start, end] = getCurrentMonth(new Date() - 3600 * 1000 * 24 * 30)
      start = new Date(start)
      end = new Date(end)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '近3天',
    value: () => {
      const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 2)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      const end = new Date()
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '近7天',
    value: () => {
      const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 6)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      const end = new Date()
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  },
  {
    text: '近30天',
    value: () => {
      const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 29)
      start.setHours(0)
      start.setMinutes(0)
      start.setSeconds(0)
      const end = new Date()
      end.setHours(23)
      end.setMinutes(59)
      end.setSeconds(59)
      return [start, end]
    }
  }
]

// 默认起止/结束时刻
export const defaultTime = [
  new Date(2000, 1, 1, 0, 0, 0),
  new Date(2000, 2, 1, 23, 59, 59)
] // '00:00:00', '23:59:59'

export default shortcuts
